package com.qf.gh.service.impl;

import com.qf.gh.dao.UserDao;
import com.qf.gh.dao.impl.UserDaoImpl;
import com.qf.gh.domain.User;
import com.qf.gh.service.UserService;

public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();
    @Override
    public boolean checkUsername(String username) {
        long count = userDao.selectCountByUsername(username);
        return count > 0;
    }

    @Override
    public boolean register(String username, String password, String email, String gender) {
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        user.setGender(gender);
        user.setEmail(email);
        user.setFlag(1);
//      user.setCode();
        int count = userDao.insert(user);
        return count == 1;
    }

    @Override
    public User login(String username, String password) {
        return userDao.select(username,password);
    }

    @Override
    public User selectById(int uid) {
        return userDao.selectById(uid);
    }
}
